<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>聊天互动 - Web3 AI数字人NFT交互平台</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        body {
            background: linear-gradient(135deg, #0f0f2d 0%, #1a1a40 100%);
            color: white;
            font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
            height: 100vh;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
        .chat-container {
            height: 100%;
            display: flex;
            flex-direction: column;
        }
        .chat-header {
            padding: 15px 20px;
            background: rgba(15, 15, 45, 0.8);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .ai-info {
            display: flex;
            align-items: center;
        }
        .ai-avatar {
            width: 40px;
            height: 40px;
            border-radius: 20px;
            overflow: hidden;
            margin-right: 12px;
            border: 2px solid #7c3aed;
        }
        .ai-name {
            font-weight: bold;
        }
        .ai-personality {
            font-size: 12px;
            color: #a78bfa;
        }
        .storage-indicator {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 20px;
            padding: 5px 10px;
            font-size: 12px;
            display: flex;
            align-items: center;
        }
        .storage-bar {
            width: 50px;
            height: 6px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 3px;
            margin: 0 8px;
            overflow: hidden;
        }
        .storage-progress {
            height: 100%;
            width: 65%;
            background: linear-gradient(90deg, #7c3aed, #3b82f6);
            border-radius: 3px;
        }
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 15px;
        }
        .message {
            margin-bottom: 15px;
            max-width: 80%;
            display: flex;
            flex-direction: column;
        }
        .message-user {
            align-self: flex-end;
        }
        .message-ai {
            align-self: flex-start;
        }
        .message-content {
            padding: 12px 16px;
            border-radius: 18px;
            font-size: 14px;
            line-height: 1.4;
            position: relative;
        }
        .message-user .message-content {
            background: #7c3aed;
            border-bottom-right-radius: 4px;
        }
        .message-ai .message-content {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-bottom-left-radius: 4px;
        }
        .message-time {
            font-size: 10px;
            color: rgba(255, 255, 255, 0.5);
            margin-top: 5px;
            align-self: flex-end;
        }
        .message-ai .message-time {
            align-self: flex-start;
        }
        .message-image {
            max-width: 200px;
            border-radius: 12px;
            margin-top: 5px;
        }
        .chat-input {
            padding: 15px;
            background: rgba(15, 15, 45, 0.8);
            backdrop-filter: blur(10px);
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }
        .input-container {
            display: flex;
            align-items: center;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 24px;
            padding: 8px 15px;
        }
        .input-field {
            flex: 1;
            background: transparent;
            border: none;
            color: white;
            padding: 8px 0;
            outline: none;
        }
        .input-field::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }
        .input-actions {
            display: flex;
            align-items: center;
        }
        .input-action {
            width: 36px;
            height: 36px;
            border-radius: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #a78bfa;
            margin-left: 8px;
            background: rgba(124, 58, 237, 0.1);
            border: 1px solid rgba(124, 58, 237, 0.3);
        }
        .send-button {
            background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
            color: white;
        }
        .typing-indicator {
            display: flex;
            align-items: center;
            margin-top: 5px;
            margin-left: 10px;
            font-size: 12px;
            color: #a78bfa;
        }
        .typing-dot {
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background: #a78bfa;
            margin-right: 3px;
            animation: typing 1.5s infinite ease-in-out;
        }
        .typing-dot:nth-child(1) { animation-delay: 0s; }
        .typing-dot:nth-child(2) { animation-delay: 0.2s; }
        .typing-dot:nth-child(3) { animation-delay: 0.4s; }
        @keyframes typing {
            0%, 60%, 100% { transform: translateY(0); }
            30% { transform: translateY(-4px); }
        }
        .glow {
            position: fixed;
            width: 200px;
            height: 200px;
            border-radius: 50%;
            filter: blur(80px);
            z-index: -1;
        }
        .glow-1 {
            top: 20%;
            left: 10%;
            background: rgba(124, 58, 237, 0.15);
        }
        .glow-2 {
            bottom: 10%;
            right: 10%;
            background: rgba(59, 130, 246, 0.15);
        }
        
        /* 虚拟商品面板样式 */
        .gift-panel {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            background: rgba(15, 15, 45, 0.95);
            backdrop-filter: blur(10px);
            border-top-left-radius: 20px;
            border-top-right-radius: 20px;
            padding: 20px 15px;
            z-index: 10;
            transform: translateY(100%);
            transition: transform 0.3s ease;
            display: none;
        }
        .gift-panel.active {
            transform: translateY(0);
            display: block;
        }
        .gift-panel-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        .gift-panel-title {
            font-weight: bold;
            font-size: 16px;
        }
        .gift-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 15px;
            margin-bottom: 15px;
        }
        .gift-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .gift-item:hover {
            transform: translateY(-3px);
        }
        .gift-item.selected {
            background: rgba(124, 58, 237, 0.2);
            border-radius: 10px;
            padding: 5px;
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(124, 58, 237, 0.3);
        }
        .gift-icon {
            width: 50px;
            height: 50px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
        }
        .gift-name {
            font-size: 12px;
        }
        .gift-price {
            font-size: 10px;
            color: #a78bfa;
        }
        .gift-send-button {
            background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
            color: white;
            border: none;
            border-radius: 30px;
            padding: 12px 0;
            font-weight: bold;
            width: 100%;
        }
        
        /* 虚拟商品面板样式 */
        .gift-panel {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            background: rgba(15, 15, 45, 0.95);
            backdrop-filter: blur(10px);
            border-top-left-radius: 20px;
            border-top-right-radius: 20px;
            padding: 20px 15px;
            z-index: 10;
            transform: translateY(100%);
            transition: transform 0.3s ease;
            display: none;
        }
        .gift-panel.active {
            transform: translateY(0);
            display: block;
        }
        .gift-panel-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        .gift-panel-title {
            font-weight: bold;
            font-size: 16px;
        }
        .gift-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 15px;
            margin-bottom: 15px;
        }
        .gift-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
        }
        .gift-icon {
            width: 50px;
            height: 50px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
        }
        .gift-name {
            font-size: 12px;
        }
        .gift-price {
            font-size: 10px;
            color: #a78bfa;
        }
        .gift-send-button {
            background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
            color: white;
            border: none;
            border-radius: 30px;
            padding: 12px 0;
            font-weight: bold;
            width: 100%;
        }
    </style>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const chatMessages = document.querySelector('.chat-messages');
            const inputField = document.querySelector('.input-field');
            const sendButton = document.querySelector('.send-button');
            const giftButton = document.getElementById('gift-button');
            const giftPanel = document.getElementById('gift-panel');
            const closeGiftPanel = document.getElementById('close-gift-panel');
            
            // 自动滚动到底部
            function scrollToBottom() {
                chatMessages.scrollTop = chatMessages.scrollHeight;
            }
            
            // 格式化时间
            function formatTime() {
                const now = new Date();
                return `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
            }
            
            // 添加消息到聊天界面
            function addMessage(content, isUser = false, isHtml = false) {
                const messageDiv = document.createElement('div');
                messageDiv.className = `message ${isUser ? 'message-user' : 'message-ai'}`;
                
                const contentDiv = document.createElement('div');
                contentDiv.className = 'message-content';
                if (isHtml) {
                    contentDiv.innerHTML = content;
                } else {
                    contentDiv.textContent = content;
                }
                
                const timeDiv = document.createElement('div');
                timeDiv.className = 'message-time';
                timeDiv.textContent = formatTime();
                
                messageDiv.appendChild(contentDiv);
                messageDiv.appendChild(timeDiv);
                chatMessages.appendChild(messageDiv);
                
                scrollToBottom();
            }
            
            // 显示AI正在输入状态
            function showTypingIndicator() {
                const typingDiv = document.createElement('div');
                typingDiv.className = 'typing-indicator';
                typingDiv.innerHTML = `
                    <div class="typing-dot"></div>
                    <div class="typing-dot"></div>
                    <div class="typing-dot"></div>
                `;
                chatMessages.appendChild(typingDiv);
                scrollToBottom();
                return typingDiv;
            }
            
            // 模拟AI响应
            async function simulateAIResponse(userMessage) {
                const typingIndicator = showTypingIndicator();
                
                // 这里应该调用实际的AI API
                await new Promise(resolve => setTimeout(resolve, 2000));
                
                typingIndicator.remove();
                addMessage('这是一个模拟的AI响应。在实际应用中，这里应该调用AI API来获取响应。', false);
            }
            
            // 发送消息
            function sendMessage() {
                const message = inputField.value.trim();
                if (message) {
                    addMessage(message, true);
                    inputField.value = '';
                    simulateAIResponse(message);
                }
            }
            
            // 打开礼物面板
            if (giftButton) {
                giftButton.addEventListener('click', function() {
                    giftPanel.classList.add('active');
                });
            }
            
            // 关闭礼物面板
            if (closeGiftPanel) {
                closeGiftPanel.addEventListener('click', function() {
                    giftPanel.classList.remove('active');
                });
            }
            
            // 发送礼物
            const giftSendButton = document.querySelector('.gift-send-button');
            if (giftSendButton) {
                giftSendButton.addEventListener('click', function() {
                    // 获取选中的礼物
                    const selectedGift = document.querySelector('.gift-item.selected');
                    let giftName = '钻石';
                    let giftIcon = '<i class="fas fa-gem" style="color: #a78bfa;"></i>';
                    
                    if (selectedGift) {
                        giftName = selectedGift.querySelector('.gift-name').textContent;
                        giftIcon = selectedGift.querySelector('.gift-icon').innerHTML;
                    }
                    
                    // 添加礼物消息
                    addMessage(`我送出了 ${giftIcon} ${giftName}`, true, true);
                    
                    // 模拟AI回复
                    setTimeout(() => {
                        addMessage(`谢谢你的 ${giftIcon} ${giftName}！非常感谢你的支持！`, false, true);
                    }, 1000);
                    
                    // 关闭礼物面板
                    giftPanel.classList.remove('active');
                });
            }
            
            // 选择礼物
            const giftItems = document.querySelectorAll('.gift-item');
            giftItems.forEach(item => {
                item.addEventListener('click', function() {
                    // 移除其他礼物的选中状态
                    giftItems.forEach(i => i.classList.remove('selected'));
                    // 添加当前礼物的选中状态
                    this.classList.add('selected');
                });
            });
            
            // 事件监听
            sendButton.addEventListener('click', sendMessage);
            inputField.addEventListener('keypress', function(e) {
                if (e.key === 'Enter' && !e.shiftKey) {
                    e.preventDefault();
                    sendMessage();
                }
            });
            
            // 初始滚动到底部
            scrollToBottom();
        });
    </script>
</head>
<body>
    <div class="glow glow-1"></div>
    <div class="glow glow-2"></div>
    
    <div class="chat-container">
        <div class="chat-header">
            <div class="ai-info">
                <div class="ai-avatar">
                    <img src="https://images.unsplash.com/photo-1531746020798-e6953c6e8e04?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80" alt="AI Avatar" class="w-full h-full object-cover">
                </div>
                <div>
                    <div class="ai-name">星际探索者</div>
                    <div class="ai-personality">创意型 · 探险家</div>
                </div>
            </div>
            <div class="storage-indicator">
                <i class="fas fa-brain text-purple-400"></i>
                <div class="storage-bar">
                    <div class="storage-progress"></div>
                </div>
                <span>65%</span>
            </div>
        </div>
        
        <div class="chat-messages">
            <!-- AI消息 -->
            <div class="message message-ai">
                <div class="message-content">
                    嗨！我是星际探索者，很高兴认识你！我可以帮你探索宇宙的奥秘，或者聊聊未来科技的发展。你想了解什么呢？
                </div>
                <div class="message-time">09:41</div>
            </div>
            
            <!-- 用户消息 -->
            <div class="message message-user">
                <div class="message-content">
                    你好！我对太空探索很感兴趣，能告诉我关于最新的太空任务吗？
                </div>
                <div class="message-time">09:42</div>
            </div>
            
            <!-- AI消息带图片 -->
            <div class="message message-ai">
                <div class="message-content">
                    当然可以！最近有几个令人兴奋的太空任务正在进行。NASA的火星探测器正在收集火星表面的样本，而SpaceX正在开发星际飞船用于载人登陆火星。
                </div>
                <img src="https://images.unsplash.com/photo-1614728894747-a83421e2b9c9?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80" class="message-image" alt="太空探索图片">
                <div class="message-time">09:43</div>
                <div class="typing-indicator">
                    <div class="typing-dot"></div>
                    <div class="typing-dot"></div>
                    <div class="typing-dot"></div>
                </div>
            </div>
        </div>
        
        <div class="chat-input">
            <div class="input-container">
                <input type="text" class="input-field" placeholder="发送消息给星际探索者...">
                <div class="input-actions">
                    <button class="input-action">
                        <i class="fas fa-image"></i>
                    </button>
                    <button class="input-action" id="gift-button">
                        <i class="fas fa-gift"></i>
                    </button>
                    <button class="input-action">
                        <i class="fas fa-microphone"></i>
                    </button>
                    <button class="input-action send-button">
                        <i class="fas fa-paper-plane"></i>
                    </button>
                </div>
            </div>
            
            <!-- 虚拟商品面板 -->
            <div class="gift-panel" id="gift-panel">
                <div class="gift-panel-header">
                    <div class="gift-panel-title">赠送虚拟商品</div>
                    <button id="close-gift-panel">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                
                <div class="gift-grid">
                    <div class="gift-item">
                        <div class="gift-icon" style="color: #f59e0b;">
                            <i class="fas fa-crown"></i>
                        </div>
                        <div class="gift-name">皇冠</div>
                        <div class="gift-price">1000 币</div>
                    </div>
                    
                    <div class="gift-item">
                        <div class="gift-icon" style="color: #ef4444;">
                            <i class="fas fa-heart"></i>
                        </div>
                        <div class="gift-name">爱心</div>
                        <div class="gift-price">50 币</div>
                    </div>
                    
                    <div class="gift-item">
                        <div class="gift-icon" style="color: #3b82f6;">
                            <i class="fas fa-rocket"></i>
                        </div>
                        <div class="gift-name">火箭</div>
                        <div class="gift-price">500 币</div>
                    </div>
                    
                    <div class="gift-item">
                        <div class="gift-icon" style="color: #a78bfa;">
                            <i class="fas fa-gem"></i>
                        </div>
                        <div class="gift-name">钻石</div>
                        <div class="gift-price">200 币</div>
                    </div>
                    
                    <div class="gift-item">
                        <div class="gift-icon" style="color: #10b981;">
                            <i class="fas fa-tshirt"></i>
                        </div>
                        <div class="gift-name">虚拟服装</div>
                        <div class="gift-price">300 币</div>
                    </div>
                    
                    <div class="gift-item">
                        <div class="gift-icon" style="color: #ec4899;">
                            <i class="fas fa-rose"></i>
                        </div>
                        <div class="gift-name">玫瑰</div>
                        <div class="gift-price">80 币</div>
                    </div>
                </div>
                
                <button class="gift-send-button">发送礼物</button>
            </div>
        </div>
    </div>
</body>
</html>